{% extends 'TopxiaWebBundle:Settings:layout.html.twig' %}

{% block title %}{{'密码修改'|trans}} - {{'安全设置'|trans}} - {{ parent() }}{% endblock %}

{% set script_controller = 'settings/password' %}
{# {% set side_nav = 'password' %} #}
{% set side_nav = 'security' %}

{% block main %}

  <div class="panel panel-default panel-col">
    <div class="panel-heading">{{'安全设置'|trans}}</div>
    <div class="panel-body">

      <ul class="breadcrumb">
        <li><a href="{{ path('settings_security') }}">{{'安全设置'|trans}}</a></li>
        <li class="active">{{'登录密码修改'|trans}}</li>
      </ul>


{% if not app.user.password %}
        <div class="alert alert-warning">
          <p>{{'当前帐号从第三方帐号直接登录时创建，尚未设置密码。'|trans}}</p>
          <p>{{'为了帐号的安全，请通过邮箱找回密码的方式，重设密码！'|trans}}</p>
          <p><a href="{{ path('password_reset') }}" class="btn btn-primary">{{'现在就去重设密码！'|trans}}</a></p>
        </div>
      {% endif %}

      <form id="settings-password-form" class="form-horizontal" method="post" {% if not app.user.password %} style="display:none;"{% endif %}>

        {{ web_macro.flash_messages() }}

        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.currentPassword, '当前密码'|trans) }}</div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.currentPassword, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.newPassword, '新密码'|trans) }}</div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.newPassword, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label">{{ form_label(form.confirmPassword, '确认密码'|trans) }}</div>
          <div class="controls col-md-8 controls">
            {{ form_widget(form.confirmPassword, {attr:{class:'form-control'}}) }}
          </div>
        </div>

        <div class="form-group">
          <div class="col-md-2 control-label"></div>
          <div class="controls col-md-8 controls">
            {{ form_rest(form) }}
            <button id="password-save-btn" data-submiting-text="{{'正在保存'|trans}}" type="submit" class="btn btn-primary">{{'提交'|trans}}</button>
          </div>
        </div>

        <input type="hidden" name="_csrf_token" value="{{ csrf_token('site') }}">

      </form>

    </div>
  </div>

{% endblock %}